package com.woniuxy.woniumall.mapper;

import com.woniuxy.woniumall.entity.Book;
import com.woniuxy.woniumall.vo.BookVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface BookMapper {
    int deleteByPrimaryKey(Integer id);

    int insert(Book record);

    Book selectByPrimaryKey(Integer id);

    List<Book> selectAll();

    int updateByPrimaryKey(Book record);

    List<BookVo> selectBookByNameAndCataId(@Param("name") String name, @Param("cataId") Integer cataId);

    BookVo selectBookByKey(int id);

    @Update("update t_book set storecount = storecount-#{count} where id = #{bid} and storecount >= #{count}")
    int updateStoreCount(@Param("bid") Integer id, @Param("count") Integer buycount);
}